package com.mikasa.springboot.example.domain.elasticsearch;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.util.Date;

/**
 * Created by User on 17/1/22.
 */

@Document(indexName = "book", type = "book", shards = 1, replicas = 0)
public class Book {

    /*ID,只能是Long或者String类型*/
    @Id
    private Long id;

    /*数值类型*/
    @Field(type = FieldType.Double)
    private Double price;

    /*数值类型*/
    @Field(type = FieldType.Integer)
    private Integer pageCount;

    /*未分词String型*/
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String isnNo;

    /*bool型*/
    @Field(type = FieldType.Boolean)
    private Boolean isValid;

    /*日期类型*/
    @Field(type = FieldType.Date, format = DateFormat.basic_time_no_millis)
    private Date publishDate;

    /*分词String类型,并设置fielddata加载限制(当然也可不设置用默认)*/
    @Field(
            type = FieldType.String,
            index = FieldIndex.analyzed,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_smart")
    private String title;

    @Field(
            type = FieldType.String,
            index = FieldIndex.analyzed,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_smart")
    private String author;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public void setPageCount(Integer pageCount) {
        this.pageCount = pageCount;
    }

    public String getIsnNo() {
        return isnNo;
    }

    public void setIsnNo(String isnNo) {
        this.isnNo = isnNo;
    }

    public Boolean getValid() {
        return isValid;
    }

    public void setValid(Boolean valid) {
        isValid = valid;
    }

    public Date getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(Date publishDate) {
        this.publishDate = publishDate;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }
}
